package com.zb.utils;

import java.util.regex.Pattern;

/**
 * 校验工具类
 * @Author WEN
 * @Date 2023/7/8 0008
 **/
public class VerificUtil {
    /**
     * 手机号正则
     */
    public static final String REGEX_PHONE = "^((13[0-9])|(14[05679])|(15([0-3,5-9]))|(16[2567])|(17[01235678])|(18[0-9]|19[135689]))\\d{8}$";

    /**
     * 大于0的正整数正则
     */
    public static final String POSITIVE_NUMBER = "^[1-9]\\d*$";

    /**
     * 金额正则表达式：带1-2位小数的正数或负数
     */
    public static final String MONEY_FORMAT = "^(\\-)?\\d+(\\.\\d{1,2})?$";

    /**
     * 校验手机号
     * @param phone
     * @return
     */
    public static boolean phoneVerific(String phone) {
        return Pattern.matches(REGEX_PHONE, phone);
    }


    public static void main(String[] args) {
        System.out.println("1 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "1"));
        System.out.println("1.1 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "1.1"));
        System.out.println("1.00 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "1.00"));
        System.out.println("+1.00 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "1.09"));
        System.out.println("0 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "0"));
        System.out.println("-1 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "-1"));
        System.out.println("-1.1 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "-1.1"));
        System.out.println("-1.12 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "-1.12"));
        System.out.println("-1.12555 >>>>>>>>" + Pattern.matches(MONEY_FORMAT, "-1.12555"));
    }

}
